<?php

    class ElementTableCreateView extends Element {
        public function Render( tString $table ) {
            global $page;

            $table = $table->Get();
            $page->SetTitle( "create table: $table" );

            Element( 'topbar/view', true );

			?><div class="main"><?php

                ?><table class="createtable createfield">
                    <tr class="title">
                        <th>Name</th>
                        <th>Type</th>
                        <th>Length</th>
                        <th>Default</th>
                        <th>Null</th>
                        <th>Auto Increment</th>
                    </tr><?php
                    Element( 'table/create/field/row', $hidden = false );
                    Element( 'table/create/field/row', $hidden = true );
                    ?><tr class="newfield" onclick="CreateTable.AddField( this.previousSibling );">
                        <td colspan="6"><img src="images/plus.png" /> Add field</td>
                    </tr>
                </table>
                <table class="createtable createindex">
                    <tr class="title">
                        <th>Name</th>
                        <th>Type</th>
                        <th>Fields</th>
                    </tr>
                    <tr>
                        <td rowspan="1">
                            <a>
                                <img class="delete" src="images/table_row_delete.png" onclick="CreateTable.RemoveField( this.parentNode.parentNode.parentNode )" />
                            </a> PRIMARY
                        </td>
                        <td rowspan="1">PRIMARY</td>
                        <td>user_id</td>
                    </tr>
                    <tr class="t">
                        <td rowspan="3">
                            <a>
                                <img class="delete" src="images/table_row_delete.png" onclick="CreateTable.RemoveField( this.parentNode.parentNode.parentNode )" />
                            </a> AUTH
                        </td>
                        <td rowspan="3">INDEX</td>
                        <td>user_name</td>
                    </tr>
                    <tr class="t">
                        <td>user_password</td>
                    </tr>
                    <tr class="t">
                        <td>user_authtoken</td>
                    </tr>
                    <tr class="newfield" onclick="CreateTable.AddIndex( this.parentNode )" >
                        <td colspan="6"><img src="images/plus.png" /> Add index</td>
                    </tr>
                </table><?php
                Element( 'modal/table/addindex' );
                Element( 'postinfo' );
            ?></div><?php
        }
    }

?>
